package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysSign;
import com.ruoyi.project.system.service.ISysSignService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户签到Controller
 * 
 * @author jjp
 * @date 2020-04-27
 */
@RestController
@Api("用户签到")
@RequestMapping("/system/sign")
public class SysSignController extends BaseController
{
    @Autowired
    private ISysSignService sysSignService;

    /**
     * 查询用户签到列表
     */
    @PreAuthorize("@ss.hasPermi('system:sign:list')")
    @ApiOperation("查询用户签到列表")
    @GetMapping("/list")
    public TableDataInfo list(SysSign sysSign)
    {
        startPage();
        List<SysSign> list = sysSignService.selectSysSignList(sysSign);
        return getDataTable(list);
    }

    /**
     * 获取用户签到详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sign:query')")
    @ApiOperation("获取用户签到详细信息")
    @GetMapping(value = "/{signId}")
    public AjaxResult getInfo(@PathVariable("signId") Long signId)
    {
        return AjaxResult.success(sysSignService.selectSysSignById(signId));
    }

    /**
     * 新增用户签到
     */
    @PreAuthorize("@ss.hasPermi('system:sign:add')")
    @ApiOperation("新增用户签到")
    @Log(title = "用户签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSign sysSign)
    {
        return toAjax(sysSignService.insertSysSign(sysSign));
    }

    /**
     * 修改用户签到
     */
    @PreAuthorize("@ss.hasPermi('system:sign:edit')")
    @ApiOperation("修改用户签到")
    @Log(title = "用户签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSign sysSign)
    {
        return toAjax(sysSignService.updateSysSign(sysSign));
    }

    /**
     * 删除用户签到
     */
    @PreAuthorize("@ss.hasPermi('system:sign:remove')")
    @ApiOperation("删除用户签到")
    @Log(title = "用户签到", businessType = BusinessType.DELETE)
	@DeleteMapping("/{signIds}")
    public AjaxResult remove(@PathVariable Long[] signIds)
    {
        return toAjax(sysSignService.deleteSysSignByIds(signIds));
    }
}
